package xju_3_4.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xju_3_4.dao.StudentDao;
import xju_3_4.entity.Stu;
import xju_3_4.service.UserService;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    // 调用持久层
    @Autowired
    private StudentDao studentDao;


    @Override
    @Transactional(timeout = 2,rollbackFor = Exception.class)
    public void insert(Stu stu) throws FileNotFoundException {
//        try {
//            Thread.sleep(4000);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
        studentDao.insert(stu);
        System.out.println("insert");
        new FileInputStream("xx");
//        int a = 1/0;

    }

    @Override
    public void update() {
        System.out.println("update");
    }

    @Override
    public void delete() {
        System.out.println("delete");
    }

    @Override
    public void query() {
        System.out.println("query");
    }
}
